//
//  LSRTagViewCell.m
//  BaiSiProject
//
//  Created by lshenrong on 16/7/7.
//  Copyright © 2016年 lshenrong. All rights reserved.
//

#import "LSRTagViewCell.h"
#import <UIImageView+WebCache.h>
@class LSRTagViewCell;
@interface  LSRTagViewCell()
//千万不要imageView作为名字，特别是在tableView里面 ，因为tableView本身就有一个imageView
//会造成程序错乱等严重问题

@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;
@property (weak, nonatomic) IBOutlet UILabel *nameLable;
@property (weak, nonatomic) IBOutlet UILabel *coutLable;

@end

@implementation LSRTagViewCell




+(instancetype)tagWithCell
{


    return [[[NSBundle mainBundle] loadNibNamed:@"LSRTagViewCell" owner:nil options:nil] lastObject];
}
-(void)setItem:(LSRTagItem *)item
{
    //显示图片
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:item.image_list] placeholderImage:[UIImage imageNamed:@"defaultUserIcon"]];
   //显示名字
    self.nameLable.text=item.theme_name;
    
    //显示订阅人数
    self.coutLable.text=item.sub_number;
    //字符串转数字
    CGFloat subNumber=[item.sub_number intValue];
    
    NSString *substring=[NSString stringWithFormat:@"%@人订阅",item.sub_number];
    self.coutLable.text=substring;
    
    if (subNumber>10000) {
        
        subNumber=subNumber/10000.0;
        
    NSString *substring=[NSString stringWithFormat:@"%.1f万人订阅",subNumber];
        
    substring=[substring stringByReplacingOccurrencesOfString:@".0" withString:@""];//去掉.0的字符创要赋值回去才行
        self.coutLable.text=substring;
    }
    
    


}
-(void)setFrame:(CGRect)frame
{
   
    
//    frame.origin.y=frame.origin.y+10;
    frame.size.height-=1;//在跳转到父类方法[super setFrame:frame]之前设置才有效
//                         为了避免压缩cell,zai cell的高度设置那里补回来
    [super setFrame:frame];
    
    
}
- (void)awakeFromNib {
    [super awakeFromNib];

    self.iconImageView.layer.cornerRadius=self.iconImageView.frame.size.width*0.5;
    
    self.iconImageView.layer.masksToBounds=YES;
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
